package com.kate.quickstart.config;

import com.kate.quickstart.pojo.Book;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;

@Configuration
public class AppConfig {

    @Resource
    private Environment environment;

    @Bean
    public Book getBook1() throws UnsupportedEncodingException {
        Book book = new Book();
        book.setName(new String( environment.getProperty("book.name")
                .getBytes("iso-8859-1"),"utf-8"));
        System.out.println(book);
        return book;
    }

    @Resource
    private Book book;
    @Bean
    public Book getBook2() throws UnsupportedEncodingException {
        System.out.println(book);
        return book;
    }
}
